package com.demo.amusic;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import java.util.Timer;
import java.util.TimerTask;

public class Welcome extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        init();

    }

    private Button btn_login ,btn_register;
    public void init() {
        btn_login = (Button) findViewById(R.id.welcomeLogin);
        btn_register = (Button) findViewById(R.id.welcomeRegister);
        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(Welcome.this,"登录",Toast.LENGTH_SHORT).show();
                toMain();
                finish();
            }
        });
        btn_register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //TODO 注册界面添加
            }
        });
    }

    public void toMain(){
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                Intent i = new Intent(Welcome.this,MainActivity.class);
                startActivity(i);
            }
        }, 1000);
    }
}